﻿using System;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
using System.Xml.Serialization;
using Grundy.Common;

namespace Grundy.Message
{
    
    [DataContract]
    [KnownType(typeof(CountedFloatingLicense))]
    [KnownType(typeof(UncountedFloatingLicense))]
    [KnownType(typeof(NodeLockedLicense))]
    public abstract class License
    {

        [DataMember]
        public Guid Id { get; set; }

        [Required]
        [DataMember]
        public string Name { get; set; }
        
        [IgnoreDataMember]
        public abstract string Type { get; }
        [Required]
        [DataMember]
        public virtual Feature Feature { get; set; }

        public override string ToString()
        {
            return "Id: {0}, Name: {1}, Type: {2}, Feature: {3}, FeatureId: {4}".FormatWith(Id, Name, Type, Feature.Name, Feature.Id);
        }
    }
}